package org.example.vueadminapi2.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.example.vueadminapi2.entity.User;
import org.example.vueadminapi2.mapper.UserMapper;
import org.example.vueadminapi2.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Transactional
@Service
public class UserServiceImpl implements UserService {
/**
 * @FileName: UserServiceImpl
 * @Description:
 * @Author: cyx
 * @date: 2025-02-24
 **/
    @Resource
    private UserMapper userMapper;
    @Override
    public User login(User user) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username",user.getUsername());
        queryWrapper.eq("password",user.getPassword());

        return userMapper.selectOne(queryWrapper);
    }

    @Override
    public User GetUserByToken(User user) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("token",user.getToken());
        return userMapper.selectOne(queryWrapper);
    }

    @Override
    public User GetUserByToken(String token) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("token",token);
        return userMapper.selectOne(queryWrapper);
    }


}
